import TabMenu from './data';
Component({
    data: {
        active: 0,
        list: TabMenu,
    },
    methods: {
        onChange(event) {
            this.setData({ active: event.detail });
            wx.switchTab({
                url: this.data.list[event.detail].url.startsWith('/')
                    ? this.data.list[event.detail].url
                    : `/${this.data.list[event.detail].url}`,
            });
        },

        init() {
            const page = getCurrentPages().pop();
            this.setData({ active: this.data.list.findIndex(item => item.url === `${page.route}`) });
        },
    }
});
